package com.igoal.entity;

import java.util.Date;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name = "user_company")
@AssociationOverrides({
	@AssociationOverride(name="pk.company", joinColumns=@JoinColumn(name="company_id")),
	@AssociationOverride(name="pk.user", joinColumns=@JoinColumn(name="user_id"))
})
public class UserCompany implements Audit {
	private static final long serialVersionUID = 3274346170162669559L;
	private UserCompanyPk pk = new UserCompanyPk();
	private Integer fromYear;
	private Integer toYear;
	private String title;
	private Date createDate;
	private Date updateDate;
	private DataStatus status;

	@EmbeddedId
	public UserCompanyPk getPk() {
		return this.pk;
	}

	public void setPk(UserCompanyPk pk) {
		this.pk = pk;
	}

	@Transient
	public User getUser() {
		return this.pk.getUser();
	}

	public void setUser(User user) {
		this.pk.setUser(user);
	}
	
	@Transient
	public Company getCompany() {
		return this.pk.getCompany();
	}

	public void setCompany(Company company) {
		this.pk.setCompany(company);
	}

	@Column(name = "from_year")
	public Integer getFromYear() {
		return this.fromYear;
	}

	public void setFromYear(Integer fromYear) {
		this.fromYear = fromYear;
	}

	@Column(name = "to_year")
	public Integer getToYear() {
		return this.toYear;
	}

	public void setToYear(Integer toYear) {
		this.toYear = toYear;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "cdate", nullable = false, length = 19)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date date) {
		this.createDate = date;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, name = "mdate")
	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date date) {
		this.updateDate = date;
	}

	@Enumerated(EnumType.STRING)
	@Column(name = "status", nullable = false, length = 50)
	public DataStatus getStatus() {
		return this.status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	@Column(name = "title")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
